package com.pty.demo.creational;

/**
 * @author pengty
 * @date 2020/3/11
 */
public class SingletonPattern {

    private static volatile SingletonPattern singletonPattern;

    private SingletonPattern() {
        System.out.println("单例被创建啦");
    }

    public static SingletonPattern createSingleton() {
        if (null == singletonPattern) {
            synchronized (SingletonPattern.class) {
                if (null == singletonPattern) {
                    singletonPattern = new SingletonPattern();
                }
            }
        }
        return singletonPattern;
    }

}
